// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        disDeckNode:{
            default:null,
            type:cc.Node
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.deckScript = this.disDeckNode.getComponent("DisPokerStack")
        this.testPokers = []
        for(let i=0;i<100;i++){
            let pokerObj = cc.gg.dataMgr.generateNewPoker(1)
            this.testPokers.push(pokerObj)
        }

        this.deckScript.initDispokerDeck(1,1000,0x02)
    },

    start () {

    },

    // update (dt) {},

    onTestDisDeckButtonsClicked:function (event) {
        let btnName = event.target.name
        if(btnName === "b1"){
            let newObj = this.testPokers.pop()
            if(!newObj){
                cc.gg.toastMgr.showToast("没有可以用的扑克了")
                return
            }
            cc.log("添加扑克：",newObj)
            this.deckScript.updateDiscardStack(this.testPokers,1,1000,0x02)
        }
    }
});
